package cn.wolfcode.web.controller;

import cn.wolfcode.common.web.Result;
import cn.wolfcode.domain.Product;
import cn.wolfcode.domain.SeckillProductVo;
import cn.wolfcode.service.ISeckillProductService;
import feign.Param;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lanxw
 * 秒杀商品信息查询
 */
@RestController
@RequestMapping("/seckillProduct")
@Slf4j
public class SeckillProductController {
    @Autowired
    private ISeckillProductService seckillProductService;

    //根据场次time查询本场秒杀的数据。
    @RequestMapping("/queryByTime")
    public Result<List<SeckillProductVo>> queryByTimeFromCache(Integer time){
        return Result.success(seckillProductService.queryByTimeFromCache(time));
    }

    @RequestMapping("/find")
    public Result<SeckillProductVo> find(Integer time,Long seckillId){
        return Result.success(seckillProductService.find(time,seckillId));
    }


    @RequestMapping("/queryByTimeForJob")
    Result<List<SeckillProductVo>> queryByTimeForJob(Integer time){
        List<SeckillProductVo> seckillProductVos = seckillProductService.queryByTime(time);
        return Result.success(seckillProductVos);
    }
}
